package com.DuoXianCheng.T05;

import java.util.ArrayList;
import java.util.Collections;

public class C01 extends Thread{
    static ArrayList<Integer> list;
    
    public C01(ArrayList<Integer> list) {
        this.list = list;
    }
    
    @Override
    public void run() {
       while (true) {
           synchronized (C01.class){
               if(list.isEmpty()){
                   break;
               } else {
                   Collections.shuffle(list);
                   Integer remove = list.remove(0);
                   System.out.println(getName() + "又产生了一个" + remove + "元大奖!");
                   
               }
           }
           try {
               Thread.sleep(100);
           } catch (InterruptedException e) {
               throw new RuntimeException(e);
           }
       }
    }
}
